<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏的商家</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style_zj.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
</head>
<body>
<!--<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>-->
<div class="content-box">
    <!--<div id="left_tab_html">
        <iframe id="left_tab" src="left_tab.html?x=5&y=3" frameborder="0"></iframe>
    </div>-->
    <div class="right-box layui-form" id="vue-box" v-cloak>
        <div class="content-admin">

            <div class="title-toggle">
                <div class="item active js-showTitle">添加轮播</div>
                <span class="btn-sty11 fr" onClick="javascript :history.back(-1);">返回</span>
            </div>
            <div class="banner-box mt30">
                <div class="mb-40">
                    <div class="clearfix mb-40">
                        <div class="fl k sort"></div>
                        <div class="img-c fl">
                            <img src="../img/addbanner.jpg" alt="" class="upload_btn">
                        </div>

                        <span class="btn-sty11" class="fl" style="margin-top: 216px;"></span>
                    </div>
                    <div class="clearfix">
                        <span class="fl k add-sty1">添加地址：</span>
                        <div class="fl wid-b60" style="width: 18%"><input type="text" class="layui-input js-linkValue"></div>
                        <span class="fl k add-sty1">开始时间：</span>
                        <input type="text" readonly="readonly" id="test1" class="layui-input js-dataVal" style="display: inline-block;width: 18%">
                    </div>
                </div>
            </div>
            <div class="text-c pb-20"><span class="btn-sty11 js-add">立即提交</span></div>

        </div>
    </div>
</div>

<!--<div>
    <iframe src="footer-record.html" style="width: 100%;border: none;height:60px;"></iframe>
</div>-->
<script src="../js/config.js"></script>

<script>


    var postData = {
        type:2,
        startTime:'',
        endTime:'',
        marketing:0,
        content:'',
        link:'',
        picUrl:'',
    };
    var app = new Vue({
        el: '#vue-box',
        data:{
            imgBaseUrl: imgBaseUrl,
        },
        mounted:function(){
        },
        methods:{

        }
    })

    //图片上传
    layui.use(['upload'], function () {
        var $ = layui.jquery, upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '.upload_btn'
            ,multiple:true
            , url: baseUrl + '/file/upload?token=' + Token
            , before: function (obj) {
                loading = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
            }
            , done: function (res, index) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg.msg('上传失败');
                } else {
                    var data = res.data;
                    postData.picUrl = data.address;
                    $('.upload_btn').attr('src',imgBaseUrl+postData.picUrl);
                    layer.close(loading);
                    console.log('上传成功！')
                }

            }
            , error: function () {

            }
        });
    })

    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#test1' //指定元素
        });
    });


    $('.js-add').click(function(){
        if(!postData.picUrl){
            layer.msg("请上传图片！")
            return
        }
        postData.link = $('.js-linkValue').val();
        postData.startTime = $('.js-dataVal').val();
        postData.content = '';

        get_ajax("/sys/banner/add", postData, function (data) {
            layer.msg('添加成功！');
            $('.upload_btn').attr('src','../img/addbanner.jpg');
            $('.js-linkValue').val('');
            $('.js-dataVal').val('');
            addNewBlack();
        })

    })




</script>
</body>
</html>